For the remaining versions, the function produces a subarray from the subscript operation specifier. The constant versions return a new valarray object, while the non-constant versions return a subarray object which has reference semantics to the original array, ready to be used as an l-value.
Parameters
- n
- Position of an element in the valarray.
Notice that the first element has the position 0, not 1.
size_t is an unsigned integral type. - slc
- A slice object specifying which elements conform the array or subarray returned.
- gslc
- A gslice object specifying which elements conform the array or subarray returned.
- msk
- A valarray with its member identifying whether each element of *this will be part of the returned valarray: If an element in *this has its corresponding element in msk set to true it is part of the returned valarray, otherwise it is not, shortening the resulting valarray.
- ind
- A valarray with its member indentifying which elements of *this will be part of the returned valarray: Each element in ind is the index of an element in *this that will be part of the returned valarray.
Return value
An element or a subarray of *this.Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
Output:
3 20 99 20 3 99 3 99 13 20 |
See also
| slice | Valarray slice selector (class) |
| gslice | Valarray generalized slice selector (class) |
| valarray::shift | Shift elements (public member function) |
